package de.philipprawe.trainingsplan.util;

import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;

public class DateUtil {
	
	private static DateUtil instance;

	/**
	 * internes Format-Objekt
	 */
	protected DateFormat dateFormat;
	
	public static final String DEFAULT_DATUM_FORMAT="dd.MM.yyyy";
	

	public static DateUtil getInstance() {
		if (instance == null)
			instance = new DateUtil(DEFAULT_DATUM_FORMAT);
		return instance;
	}
	
	private DateUtil(String dateFormat){
		
	}
	
	public static Date parseDate(String dateAsString){
		String[] temp = dateAsString.split("\\.");
		Calendar cal = new GregorianCalendar(Locale.GERMAN);
		cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(temp[0]));
		cal.set(Calendar.MONTH, Integer.parseInt(temp[1]));
		cal.set(Calendar.YEAR, Integer.parseInt(temp[2]));
		Date returnDate = cal.getTime();
		return returnDate;
	}

}
